home *** CD-ROM | disk | FTP | other *** search
/ SGI Developer Toolbox 6.1 / SGI Developer Toolbox 6.1 - Disc 4.iso / src / haeberli / vidtools / videcho.c < prev    next >
C/C++ Source or Header  |  1994-08-01  |  2KB  |  71 lines

  1. /*
  2.  * Copyright 1991, 1992, 1993, 1994, Silicon Graphics, Inc.
  3.  * All Rights Reserved.
  4.  *
  5.  * This is UNPUBLISHED PROPRIETARY SOURCE CODE of Silicon Graphics, Inc.;
  6.  * the contents of this file may not be disclosed to third parties, copied or
  7.  * duplicated in any form, in whole or in part, without the prior written
  8.  * permission of Silicon Graphics, Inc.
  9.  *
  10.  * RESTRICTED RIGHTS LEGEND:
  11.  * Use, duplication or disclosure by the Government is subject to restrictions
  12.  * as set forth in subdivision (c)(1)(ii) of the Rights in Technical Data
  13.  * and Computer Software clause at DFARS 252.227-7013, and/or in similar or
  14.  * successor clauses in the FAR, DOD or NASA FAR Supplement. Unpublished -
  15.  * rights reserved under the Copyright Laws of the United States.
  16.  */
  17. /*
  18.  *    videcho - 
  19.  *        Echo video in time
  20.  *
  21.  *            Paul Haeberli - 1992
  22.  */
  23. #include "math.h"
  24. #include "stdio.h"
  25. #include "canvas.h"
  26.  
  27. main(argc,argv)
  28. char    **argv;
  29. {
  30.     canvas *c, *old, **last;
  31.     float blend;
  32.     int i, nframes, inpos, feedback;
  33.     
  34.     if(argc < 3) {
  35.     fprintf(stderr,"usage: videcho nframes blend [-f]\n");
  36.     exit(1);
  37.     }
  38.     if(argc>3)
  39.        feedback = 1;
  40.     else
  41.        feedback = 0;
  42.     nframes = atoi(argv[1]);
  43.     blend = atof(argv[2]);
  44.     last = 0;
  45.     while(c=filetocanvas(stdin)) {
  46.     if(!last) {
  47.         last = (canvas **) malloc(nframes*sizeof(canvas *));
  48.         for(i=0; i<nframes; i++)
  49.         last[i] = 0;
  50.         inpos = 0;
  51.     }
  52.     old =last[inpos];
  53.     if(feedback) {
  54.         if(old) {
  55.         blendcanvas(c,old,c,blend);
  56.         freecanvas(old);
  57.         }
  58.         last[inpos] = clonecanvas(c);
  59.     } else {
  60.         last[inpos] = clonecanvas(c);
  61.         if(old) {
  62.         blendcanvas(c,old,c,blend);
  63.         freecanvas(old);
  64.         }
  65.     }
  66.     canvastofile(c,stdout);
  67.     inpos = (inpos+1)%nframes;
  68.     }
  69.     exit(0);
  70. }
  71.